<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<script src="./lib/template-web.js"></script>
	<script src="./lib/jquery.js"></script>

	<script src="https://cdn.bootcdn.net/ajax/libs/dayjs/1.4.1/dayjs.min.js"></script>
</head>

<body>
	<ul>

	</ul>


	<script type='text/html' id="tpl">
		==={{name}}
		
		==={{pp(time,'YYYY-MM-DD HH:mm:ss')}}
		{{each newArr}}
	<li>第1个li=====name：{{$value.name}} ==== id：{{$value.id}}===索引：{{$index}}</li>
	{{/each}}
	</script>

	<!-- <script type='text/html' id="tpl">
		====<%=time|pp%>
		<%  for(var  i=0;i< newArr.length;i++){ %>
		<li>第1个li====姓名:<%=newArr[i].name %> 索引：<%=i%> </li>
		<%}%>
	</script> -->

	<script>
		/* 过滤器 */
		template.defaults.imports.pp = (value, str) => {
			console.log(value, str, 8888);
			return dayjs(value).format(str)
		}
		var arr = [{
				id: 1,
				name: 'jack'
			},
			{
				id: 2,
				name: 'jack2'
			},
			{
				id: 3,
				name: 'jack3'
			},
		]
		var html = template('tpl', {
			newArr: arr,
			time: new Date()
		})

		$('ul').html(html)
	</script>


</body>

</html>
